<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            padding: 0;
            margin: 0;
        }
        [v-cloak]{
            display: none;
        }
        .text{
            text-align: center;
            height: 100%;
            width: 100%;
            line-height: 50px;
            position: fixed;
            top: 0px;
            color: white;
        }
        html,body,#box,.content{
            height: 100%;
        }
        #box{
            background-color: #ccc;
        }
        .content{
            background-color: #fff;
        }
    </style>
</head>
<body>
    <div id="box" v-cloak>
        <div class="text">
            刷新中。。。
        </div>
        <div class="content" v-list="type_list">
            <div v-for="i in num">{{i}}</div>
        </div>
    </div>
</body>
<script src="../js/vue.js"></script>
<script>
    Vue.directive('list',{
        inserted(dom,json){
            dom.style.position='relative'
            dom.zIndex=1
           
            
            dom.onmousedown=function(event){
                dom.style.transition=''
                var oEv_y=event.clientY
                var type=false
                dom.onmousemove=function(event){
                    var new_y=event.clientY
                    if(new_y>oEv_y){
                        var num=new_y - oEv_y
                        if(num > 100){
                            type=true
                        }
                        dom.style.top=num+'px'
                    }
                }
                dom.onmouseup=function(){
                    dom.onmousemove=''
                    dom.style.transition='all .5s'
                    if(type){
                        dom.style.top='50px'
                        json.value(true)
                    }else{
                        dom.style.top='0px'
                        json.value(false)
                    }
                }
            }
            console.log(json);
        },
        update(dom){
            dom.style.top='0px'
        }
    })
    new Vue({
        el:"#box",
        data:{
            num:5,
        },
        methods:{
            type_list(type){
                if(type){
                    setTimeout(()=>{
                        this.num=10
                    },2000)
                }
            }
        }
    })
</script>
</html>